<?php
/********************************************************
** Copyright 2010-2013. Todos los derechos reservados. **
** Desarrollado y Gestionado por:					   **
** Sugey Quintero (Analista)						   **
** José G. De Freitas (Programador)					   **
** Klaudia Uribe (Diseñadora Web)					   **
** Cesar Isturiz (Diseñador Web)					   **
**				S E A  v1.0							   **
*********************************************************/

session_start();
include("conexion2.php");

	if (isset($_SESSION['name']) and isset($_SESSION['tiempo'])) {
        include("Tiempo.php");
		date_default_timezone_set('America/Caracas'); setlocale(LC_TIME, 'spanish');
		$usuario = $_SESSION['name'];
		$fecha = date("Y-m-d H:i:s");
		$auditoria = mysql_query("INSERT INTO auditoria SELECT '$usuario', '$fecha' , 'Registro de asistencias estudiantes liceo' ");

    }else {
		echo "<script>alert('Debe ingresar al sistema primero');</script>";
		echo "<script>document.location.href='index.php';</script>";
	}
include("conexion.php");

$periodo=$_GET['periodo'];
$lapso=$_GET['lapso'];
$materia=$_GET['materia'];
$grado=$_GET['grado'];
$seccion=$_GET['seccion'];

if($grado && $seccion){
	$resultado=mysql_query("SELECT alumno.CI_a, alumno.nombre_a, alumno.apellido_a FROM alumno INNER JOIN inscripcion ON alumno.CI_a=inscripcion.cedula_a WHERE inscripcion.periodo='$periodo' AND inscripcion.grado='$grado' AND inscripcion.seccion='$seccion' order by alumno.CI_a");
	$sql = mysql_fetch_array(mysql_query("SELECT nombre_m FROM materia WHERE Cod_m='$materia' "));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Asistencia Estudiante</title>
<link rel="shortcut icon" type="image/x-icon" href="../favicon.ico">
<link href="style.css" rel="stylesheet" type="text/css" />
<!-- calendario-->
<link rel="stylesheet" type="text/css" href="src/css/jscal2.css" />
<link rel="stylesheet" type="text/css" href="src/css/border-radius.css" />
<link rel="stylesheet" type="text/css" href="src/css/steel/steel.css" />
<script type="text/javascript" src="src/js/jscal2.js"></script>
<script type="text/javascript" src="src/js/lang/es.js"></script>
<!-- fin calendario-->
<!-- botones-->
<link type="text/css" href="js/css/smoothness/jquery-ui-1.8.16.custom.css" rel="Stylesheet" />      
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
<script src="js/prototype.js" type="text/javascript"></script>
<script language="JavaScript" src="js/valida_p.js"></script>
<script>
var j$ = jQuery.noConflict();
j$(document).ready(function(){
j$(".button").button();
});

j$(function(){
	j$('#menu li a').click(function(event){
		var elem = j$(this).next();
		if(elem.is('ul')){
			event.preventDefault();
			j$('#menu ul:visible').not(elem).slideUp();
			elem.slideToggle();
		}
	});
});

function SeleccionarMaterias(mat) {
	var o;
	document.forms.materias.grado.disabled = true;
		<?php $materias = mysql_query("SELECT * FROM materia");
				while($mat = mysql_fetch_array($materias)) { ?>
	if(mat == "<?php echo $mat[2]; ?>") {
		o = document.createElement("OPTION");
		o.text="<?php echo $mat[1]; ?>";
		o.value="<?php echo $mat[0]; ?>";
		document.forms.materias.materia.options.add(o);
	}
<?php } ?>
			document.forms.materias.materia.disabled = false;
	}
function ComponerMaterias(mat) {
	document.forms.materias.grado.disabled = true;
		for(var i=document.forms.materias.materia.options.length-1; i>0; i--){
			document.forms.materias.materia.remove(i);
		}
	SeleccionarMaterias(mat);
	document.forms.materias.grado.disabled = false;
}

var nav4 = window.Event ? true : false;
function acceptNum(evt){   
var key = nav4 ? evt.which : evt.keyCode;   
return (key <= 13 || (key>= 48 && key <= 57));
}

function ComprobarAsistencia(valor){    
	if(valor.value > 20){
		valor.value="";
        valor.focus();
	return false;
	}
	else{
		return true;
	}
}
</script>
<!-- fin botones-->
</head>

<body>
<div id="wrap">
<div id="header">
<div id="hora">
<?php include("Hora.php"); ?>
</div>
<div id="topnav">
	<?php include("MenuSuperior.php"); ?>
</div>
</div>
<div id="content">
<div id="left">
<div class="post">
<div class="post_h">

</div>

<div class="postcontent">

<blockquote><h2 align="center">ASISTENCIA ESTUDIANTE</h2></blockquote>
	<fieldset>
	<legend align=left><b><font size=2>BUSCADOR</font></b></legend>
		<form action="plani_asis_alum.php" method=get name=materias>
		<table width=100% cellspacing=3 cellpadding=0 border=0>
			<tr>
				<td width=80% align=right><select name=grado onChange='ComponerMaterias(this.options[this.selectedIndex].value)'>
						<option>Grado</option>
						<option value='1er' <?php if ($grado=='1er'){ echo "Selected"; } ?>>1er A&ntilde;o</option>
						<option value='2do' <?php if ($grado=='2do'){ echo "Selected"; } ?>>2do A&ntilde;o</option>
						<option value='3er' <?php if ($grado=='3er'){ echo "Selected"; } ?>>3er A&ntilde;o</option></select>
					<select name=seccion>
						<option>Secci&oacute;n</option>
						<option value='A' <?php if ($seccion=='A'){ echo "Selected"; } ?>>A</option>
						<option value='B' <?php if ($seccion=='B'){ echo "Selected"; } ?>>B</option></select>
					<select name=materia onclick=Devolver();>
						<option>Materia</option></select>
					<select name=lapso><option>Lapso</option>
						<option value='1er Lapso' <?php if ($lapso=='1er Lapso'){ echo "Selected"; } ?>>1er Lapso</option>
						<option value='2do Lapso' <?php if ($lapso=='2do Lapso'){ echo "Selected"; } ?>>2do Lapso</option>
						<option value='3er Lapso' <?php if ($lapso=='3er Lapso'){ echo "Selected"; } ?>>3er Lapso</option></select></td>
					<input type=hidden name='periodo' value='<?php if(date(m)>=8){ $anio=date(Y); $anio2=$anio+1; echo "$anio - $anio2"; } else{ $anio=date(Y)-1; $anio2=$anio+1; echo "$anio - $anio2"; } ?>'>
				<td><input class=button type=submit value='Buscar'></td>
			</tr>
		</form>
		</table>
	</fieldset>

<div class="post">
<span></span></div>

<?php if($resultado){
	echo "
		<fieldset>
		<legend align=left><b><font size=2>MATERIA: ".strtoupper($sql[0])."</font></b></legend>
			<form action=res_asis_alum.php method=post>
			<table width=100% cellspacing=3 cellpadding=0 border=0>
				<tr><td><br></td></tr>
				<tr>
					<th></th>
					<th>CEDULA</th>
					<th>NOMBRES Y APELLIDOS</th>
					<th>INAS.</th>
					<th>OBSERVACIONES</th>	
				</tr>
				<tr>
					<th></th>
					<th></th>
					<th></th>
					<td align=center><label style='font-family: Verdana, Arial, san-serif; font-size: 10px; font-style: italic; color: #FF0000'>Cant. M&aacute;x. 20</label></td>
				</tr>";
$a=1;
while ($row=mysql_fetch_array($resultado)){
	if($lapso == '1er Lapso'){
		$buscar = mysql_fetch_array(mysql_query("select lapso1, obs1 from asistencia_a where periodo='$periodo' and CI_al='$row[0]' and Cod_m='$materia'"));
	}else if($lapso == '2do Lapso'){
		$buscar = mysql_fetch_array(mysql_query("select lapso2, obs2 from asistencia_a where periodo='$periodo' and CI_al='$row[0]' and Cod_m='$materia'"));
	}else if($lapso == '3er Lapso'){
		$buscar = mysql_fetch_array(mysql_query("select lapso3, obs3 from asistencia_a where periodo='$periodo' and CI_al='$row[0]' and Cod_m='$materia'"));
	}
			echo "<tr>
					<td>$a</td>
					<td><a href='datos_gen_a.php?cedula=$row[0]' title='Click aqui para visualizar o actualizar los datos del estudiante'>$row[0]</a></td>
					<input name=cedula[] type=hidden value='$row[0]'>
					<td align=center>$row[1] $row[2]</td>
					<td align=center><input type=text size=2 maxLength=2 name=ina[] value='$buscar[0]' onKeyPress=\"return acceptNum(event)\" onkeyup=\"ComprobarAsistencia(this)\"></td>
					<td><textarea cols=15 rows=2 name=obs_a[] value='$buscra[1]'></textarea></td>
					<input type=hidden value=$materia name=materia><input type=hidden value='$lapso' name=lapso>
				</tr>"; $a++;
	}
		echo "</table>
		</fieldset>

<div class=post>
<span></span></div>

<div id=botonera align=center>
	<input class=button type=submit value=Guardar>
	<input class=button type=button value=Cancelar onClick=location='index.php'>
</div>
</form>";
} ?>

</div>
<div class="post_b">
<span></span></div>
</div>


</div>

<div class="post">
<div class="post_h">

</div>


</div>

<?php include("Menu.php"); ?>

<div class="clear"></div>
</div>
<div id="pagebottom"></div>

<div id="footer">
<P>&reg; Derechos Reservados @ CopyRight. 2011-2012</P>
<p>Programadores: Quintero E, Isturiz C, Uribe C, De Freitas J.</p>
</div>
</div>
</body>
</html>
